﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SkinableFormsLib
{
    public class LWLabelScrollable : LWLabel
    {
        internal string _text;
        public new  string Text
        {
            get
            {
                return _text;
            }
            set
            {
                _text = value;
                //base.Text = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="characterCount">positive for RTL scroll / negative for LTR scroll</param>
        /// <returns></returns>
        private string ScrollText(int characterCount)
        {
            if (_text.Length == 0)
                return _text;
            int pos = (_text.Length + characterCount) % _text.Length;


            string ret = _text.Substring(pos, _text.Length - pos) + " " + _text.Substring(0, pos);
            return ret;
        }

        private int _lwScrollShift = 0;
        public int LWScrollShift
        {
            get
            {
                return _lwScrollShift;
            }
            set
            {
                _lwScrollShift = value;
            }

        }


        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.Text = ScrollText(_lwScrollShift);
            base.OnPaint(e);
        }
    }
}
